package com.teach.controller.certificate;



import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import com.teach.commons.Id;
import com.teach.dto.CertificateInfoSearch;
import com.teach.dto.CertificateListAllSearch;
import com.teach.entity.CertificateType;
import com.teach.mapper.CertificateInfoMapper;
import com.teach.service.CertificateInfoService;
import com.teach.service.CertificateTypeService;

import lombok.extern.slf4j.Slf4j;

@Controller
@RequestMapping("/certificate")
@Slf4j
public class CertificateIndexController {

	@Autowired
	CertificateInfoService cis;
	@Autowired
	CertificateTypeService cts;
	@Autowired
	Id id;
	@Autowired
	CertificateInfoMapper mapper;

	@GetMapping("/certificate.html")
	public String doIndex() {
		return "certificate/index";
	}
	
	@RequestMapping("/certificateInfo.do")
	@ResponseBody
	public CertificateListAllSearch doGet(Model model,Long infoCertificateId,CertificateListAllSearch allSearch) {
		log.debug("infoCertificateId={}",infoCertificateId);
		log.debug("打印：allSearch={}",allSearch);
		return mapper.selectType(infoCertificateId);
	}

	@GetMapping("/certificate-index.html")
	public String doCertificateIndex( Model model,Long infoCertificateId ) {
				model.addAttribute("infoCertificate", cis.getinfoCertificateId(infoCertificateId));
		return "certificate/certificate-index";
	}
	
	@GetMapping("/certificate-payment.html")
	public String doPayment(Model model,Long obj) {
		model.addAttribute("obj", cts.get(obj));
		return "certificate/certificate-payment";

	}

	@PostMapping("/certificate-zhifubao.html")
	public String doZhiFuBao() {
		return "certificate/certificate-zhifubao";

	}

	@PostMapping("/certificate.alipay.trade.page.pay.html")
	public String doAlipay() {
		return "certificate.alipay.trade.page.pay";

	}

	@RequestMapping("/certificate-class-list.s")
	@ResponseBody
	public List<CertificateType> doList() {
		log.debug("{}", cts.listAll());
		return cts.listAll();
	}

	@RequestMapping("/certificate-page-ajax.s")
	@ResponseBody
	public Object doAjaxPage(CertificateInfoSearch search) {
		log.debug("{}", search);
		return cis.page(search);
	}

}
